import {productMessages} from "../goods.js";

export let name = "product-Parameter-page";
export function Render(){
    return `
    <style>
    /*参数详情*/
    .parameterpage{
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 1000;
    }
    .parameterpage .parameterContent{
    width: 100%;
    height: 25%;
    background-color: white;
    border-radius: 3rem 3rem 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    padding: 1rem 1.5rem;
    overflow: auto;
    }
    .parameterpage .parameterContent h1{
    font-size: 3rem;
    margin-bottom: 2rem;
    margin-top: 2rem;
    position: fixed;
    top: 75%;
    left: 2rem;
    }
    .parameterpage .parameterContent ul{
    width: 100%;
    margin-top: 8rem;
    margin-bottom: 10rem;
    }
    .parameterpage .parameterContent ul li{
    margin: 4rem 0 2rem 2rem;
    height: 6rem;
    border-bottom: 0.1rem solid #ccc;
    }
    .parameterpage .parameterContent ul li .key{
    font-size: 2.4rem;
    margin-bottom: 2rem;
    }
    .parameterpage .parameterContent ul li .value{
    font-size: 2.2rem;
    color: #999999;
    line-height: 3rem;
    margin-left: 5rem;
    }
    .parameter-btn{
    width: 98%;
    height: 6rem;
    background:linear-gradient(90deg, #2aae67 , rgba(42, 174, 103, .8)) ;
    color: #fff;
    border-radius: 2rem;
    font-size: 2.6rem;
    margin-left: 1%;
    margin-top: 1rem;
    }
    .btns{
    width: 100%;
    background-color: white;
    height: 6rem;
    position: fixed;
    bottom: 2rem;
    left: 0;
    }
    .parameterpage .backGround{
    height: 75%;
    }
</style>
    `
}
export function afterRender(){
    //参数详情页面的显示和隐藏
    let parameter1 = document.querySelector(".parameter");
    let parameterpage = document.querySelector(".parameterpage");
    parameter1.addEventListener("click", function () {
        parameterpage.style.display = "block";
    })
    let parameterBtn = document.querySelector(".parameter-btn");
    parameterBtn.addEventListener("click", function () {
        let fatherDiv = parameterBtn.parentElement.parentElement;
        fatherDiv.style.display = "none";
    })
//动态创建参数详情页面的数据内容
    let hash = location.hash.slice(1);
    let ul = document.querySelector(" .parameterpage ul");
    let parameter = document.querySelector(".parameter .text");
    productMessages[hash].parameter.forEach(function (item) {
        parameter.innerHTML += `
        ${item.key}·
        `;
        ul.innerHTML += `
        <li><span class="key">${item.key}</span><span class="value">${item.value}</span></li>
        `;
    });
}